package com.cwf.quality.model.vo;

import com.cwf.quality.common.enums.ResponseEnum;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import lombok.NoArgsConstructor;


@Data
@NoArgsConstructor
@JsonIgnoreProperties
public class ResultResponse<T> {

    private int code = ResponseEnum.SUCEESS.getCode();
    private String msg;
    private T data;

    public ResultResponse success() {
        this.code = ResponseEnum.SUCEESS.getCode();
        this.msg = ResponseEnum.SUCEESS.getMessage();
        return this;
    }

    public ResultResponse success(T data) {
        this.code = ResponseEnum.SUCEESS.getCode();
        this.msg = ResponseEnum.SUCEESS.getMessage();
        this.data = data;
        return this;
    }

    public ResultResponse fail() {
        this.code = ResponseEnum.FAIL.getCode();
        this.msg = ResponseEnum.FAIL.getMessage();
        return this;
    }

    public ResultResponse fail(int code, String msg) {
        this.code = code;
        this.msg = msg;
        return this;
    }

    public ResultResponse fail(String msg) {
        this.code = ResponseEnum.FAIL.getCode();
        this.msg = msg;
        return this;
    }

}
